<template>
	<view>
		<u-navbar title-color="#fff" :borderBottom="false" title="直播专区" titleColor="#FFFFFF" backIconSize="40"
		 back-icon-color="#ffffff" :background="background">
		</u-navbar>
		<view class="top">
			<view class="left">
				<image src="../static/a1.png" class="a1"></image>
				<view class="name">
					排行榜
				</view>
				<view class="list" v-for="(item,index) in ranking_list" :key="index">
					<image :src="'../../../static/image/cc'+(index+1)+'.png'" class="head"></image>
					<view class="user" :class="'u'+(index+1)">
						<image :src="img_pre+item.head_img" class="img"></image>
					</view>
				</view>
			</view>
			<view class="right">
				<image src="../static/b1.png" class="b1"></image>
				<view class="b2">
					<view class="name">
						活动中心
					</view>
					<view class="text">
						100人参与
					</view>
				</view>
			</view>
		</view>
		<view class="div"></view>
		<view class="content">
			<view class="title">
				<view class="left">
					热门主播
				</view>
				<view class="right" v-if="false" @click="toPage('attention')">
					关注列表 <image src="../static/a2.png" mode=""></image>
				</view>
			</view>
			<u-row>
				<u-col :span="6" v-for="(item,index) in list" :key="index">
					<view class="list" @click="toLook(item)">
						<view class="type" v-if="item.playing==1">
							<view class="icon"></view> 直播中
						</view>
						<view class="attention a1" v-if="true">
							<image src="../static/a3.png"></image>
							<view class="text">
								关注
							</view>
						</view>
						<view class="attention a2" v-else>
							<image src="../static/a4.png"></image>
							<view class="text">
								关注
							</view>
						</view>
						<image :src="img_pre+item.cover" class="background"></image>
						<view class="user">
							<image :src="getHead(item.head_img)" class="head"></image>
							<view class="name">
								{{item.nickname}}
							</view>
							<view class="heat">
								<image src="../static/b2.png" mode=""></image> {{item.heat}}
							</view>
						</view>
					</view>

				</u-col>
			</u-row>
		</view>
	</view>
</template>

<script>
	var than;
	export default {
		data() {
			return {
				background: {
					'background': '#00074E'
				},
				page: 1,
				list: [],
				ranking_list: []
			}
		},
		onLoad(option) {
			than = this;
			than.getList();
			than.post('api/live_video/listOfGift', null, function(data) {
				getApp().globalData.gift = [];
				getApp().globalData.gift = data;
			})
		},
		onReachBottom() {
			than.page++;
			than.getList();
		},
		methods: {
			toLook(id) {
				if (id.playing == 1) {
					than.toPage('index?pull_address=' + id.pull_address + '&lrid=' + id.lrid)
				} else {
					than.toast('没开播')
				}
			},
			getList() {
				than.post("api/live_video/listOfData", {
					page: than.page
				}, function(data) {
					than.ranking_list = data.ranking_list
					if (than.page == 1) {
						than.list = data.list;
					} else {
						than.list = than.list.concat(data.list);
					}
				})
			}
		}
	}
</script>

<style lang="less">
	page {
		background-color: #2A004D;
	}

	.div {
		background: #00074C;
		height: 100rpx;
	}

	.top {
		display: flex;
		align-items: center;
		height: 191rpx;
		background: #00074C;

		.left {
			width: 455rpx;
			height: 117rpx;
			background: linear-gradient(90deg, #d92bd0, #642fe2);
			border-radius: 0 100rpx 100rpx 0;
			display: flex;
			align-items: center;

			.a1 {
				width: 38rpx;
				height: 42rpx;
				margin: 0 11rpx 0 24rpx;
			}

			.name {
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #FFFFFF;
			}

			.list {
				position: relative;
				display: flex;
				align-items: center;
				justify-content: center;
				width: 90rpx;
				height: 90rpx;


				.head {
					left: 0;
					top: 0;
					position: absolute;
					z-index: 1;
					width: 30rpx;
					height: 26rpx;

				}

				.user {
					width: 68rpx;
					height: 68rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					border-radius: 50%;

					.img {
						width: 60rpx;
						height: 60rpx;
						border-radius: 50%;
					}
				}

				.u1 {
					background: #FCD012;
				}

				.u2 {
					background: #C5D3E3;
				}

				.u3 {
					background: #F9A771;
				}
			}
		}

		.right {
			display: flex;
			align-items: center;
			margin-left: auto;
			margin-right: 23rpx;
			width: 247rpx;
			height: 117rpx;
			background: linear-gradient(90deg, #fd332e, #f90b75);
			border-radius: 100rpx;

			.b1 {
				width: 25rpx;
				height: 49rpx;
				margin: 0 25rpx;
			}

			.b2 {
				.name {
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #FFFFFF;
				}

				.text {
					font-size: 22rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: rgba(255, 255, 255, 0.6);
				}
			}
		}
	}

	.content {
		border-radius: 70rpx 0 0 0;
		position: relative;
		background-color: #2A004D;
		z-index: 1;
		margin-top: -100rpx;

		.title {
			height: 121rpx;
			display: flex;
			align-items: center;
			padding: 0 25rpx;
			border-radius: 70rpx 0 0 0;

			.left {
				font-size: 38rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #FFFFFF;
			}

			.right {
				display: flex;
				align-items: center;
				margin-left: auto;
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: rgba(255, 255, 255, 0.8);

				image {
					margin-left: 14rpx;
					width: 38rpx;
					height: 31rpx;
				}
			}
		}

		.list {
			width: 357rpx;
			height: 361rpx;
			border-radius: 20rpx;
			margin-bottom: 12rpx;
			position: relative;

			.type {
				position: absolute;
				left: 0;
				top: 0;
				z-index: 10;
				width: 121rpx;
				height: 42rpx;
				background: rgba(0, 0, 0, 0.45);
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #30FF00;
				border-radius: 20rpx 0rpx 20rpx 0px;
				display: flex;
				align-items: center;
				justify-content: center;

				.icon {
					width: 16rpx;
					height: 16rpx;
					background: #00FF0C;
					margin-right: 10rpx;
					border-radius: 50%;
				}
			}

			.a1 {
				background: linear-gradient(90deg, #F56C42, #FBA21F);

				.text {
					color: #EBF1FD;
				}
			}

			.a2 {
				background: #2C130C;

				.text {
					color: #F9D131;
				}
			}


			.attention {
				top: 12rpx;
				right: 12rpx;
				position: absolute;
				width: 114rpx;
				height: 42rpx;
				border-radius: 21rpx;
				z-index: 2;
				display: flex;
				align-items: center;
				justify-content: center;

				image {
					width: 29rpx;
					height: 26rpx;
				}

				.text {
					margin-top: -5rpx;
					margin-left: 9rpx;
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 500;
				}
			}

			.background {
				border-radius: 20rpx;
				width: 100%;
				height: 100%;
				position: absolute;
				top: 0;
				z-index: 1;
			}

			.user {
				position: absolute;
				width: 100%;
				bottom: 0;
				z-index: 10;
				display: flex;
				align-items: center;
				height: 74rpx;

				.head {
					width: 50rpx;
					height: 50rpx;
					border-radius: 50%;
					margin: 0 12rpx;
				}

				.name {
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #FFFFFF;
				}

				.heat {
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #FFFFFF;
					margin-left: auto;
					margin-right: 12rpx;

					image {
						margin-right: 9rpx;
						width: 18rpx;
						height: 21rpx;
					}
				}
			}
		}
	}
</style>
